// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   JFrameUtilities.java

package org.quickserver.swing;

import java.awt.*;
import java.io.PrintStream;
import javax.swing.*;

public class JFrameUtilities
{

    public JFrameUtilities()
    {
    }

    public static String title(Object o)
    {
        String t = o.getClass().toString();
        if(t.indexOf("class") != -1)
            t = t.substring(6);
        if(t.lastIndexOf(".") != -1)
            t = t.substring(t.lastIndexOf(".") + 1);
        return t;
    }

    public static void run(JFrame frame, int width, int height)
    {
        frame.setDefaultCloseOperation(3);
        frame.setSize(width, height);
        frame.setVisible(true);
    }

    public static void run(JApplet applet, int width, int height)
    {
        JFrame frame = new JFrame(title(applet));
        frame.setDefaultCloseOperation(3);
        frame.getContentPane().add(applet);
        frame.setSize(width, height);
        applet.init();
        applet.start();
        frame.setVisible(true);
    }

    public static void run(JPanel panel, int width, int height)
    {
        JFrame frame = new JFrame(title(panel));
        frame.setDefaultCloseOperation(3);
        frame.getContentPane().add(panel);
        frame.setSize(width, height);
        frame.setVisible(true);
    }

    public static void setNativeLookAndFeel()
    {
        try
        {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        catch(Exception e)
        {
            System.out.println((new StringBuilder("Error setting native LAF: ")).append(e).toString());
        }
    }

    public static void setJavaLookAndFeel()
    {
        try
        {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        }
        catch(Exception e)
        {
            System.out.println((new StringBuilder("Error setting Java LAF: ")).append(e).toString());
        }
    }

    public static void setMotifLookAndFeel()
    {
        try
        {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
        }
        catch(Exception e)
        {
            System.out.println((new StringBuilder("Error setting Motif LAF: ")).append(e).toString());
        }
    }

    public static void centerWindow(Window window)
    {
        Dimension dim = window.getToolkit().getScreenSize();
        window.setLocation(dim.width / 2 - window.getWidth() / 2, dim.height / 2 - window.getHeight() / 2);
    }
}
